package com.example.teatea.controller;

import com.example.teatea.dao.ChangeMenu;
import com.example.teatea.dao.ChangeSeat;
import com.example.teatea.dao.GetMenu;
import javafx.event.ActionEvent;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.stage.Stage;

import java.net.URL;
import java.util.ResourceBundle;

public class ChangeSeatController implements Initializable {

    public ComboBox combox;
    public Button sureBt;

    public void toSure(ActionEvent actionEvent) {
        int oldSeat = SeatController.nowSeat;
        int menu = new GetMenu().getMenu(oldSeat);
        if(combox.getValue().equals("一号桌")){
            SeatController.nowSeat = 1;
        }else if(combox.getValue().equals("二号桌")){
            SeatController.nowSeat = 2;
        }else if(combox.getValue().equals("三号桌")){
            SeatController.nowSeat = 3;
        }else if(combox.getValue().equals("四号桌")){
            SeatController.nowSeat = 4;
        }else if(combox.getValue().equals("五号桌")){
            SeatController.nowSeat = 5;
        }else if(combox.getValue().equals("六号桌")){
            SeatController.nowSeat = 6;
        }
        new ChangeSeat().changeSeatState0(oldSeat);
        new ChangeSeat().changeSeatState1(SeatController.nowSeat);
        new ChangeMenu().changeMenu(SeatController.nowSeat,oldSeat,menu);
        Stage stage = (Stage) sureBt.getScene().getWindow();
        stage.close();
    }

    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {
        combox.getItems().add("一号桌");
        combox.getItems().add("二号桌");
        combox.getItems().add("三号桌");
        combox.getItems().add("四号桌");
        combox.getItems().add("五号桌");
        combox.getItems().add("六号桌");
        combox.setValue("一号桌");
    }
}
